$(function(){
	//类型选择（近24小时、近30天、近一年）
	$(".type span").click(function(){
		$(this).siblings().find("font").removeClass("active");
		$(this).find("font").addClass("active");
	});
});

//全屏重绘echarts报表
function fullScreenRefreshEcharts(myChart1, maChart2, maChart3, maChart4, maChart5, maChart6, maChart7){
	myChart1.resize();
	maChart2.resize();
	maChart3.resize();
	maChart4.resize();
	maChart5.resize();
	maChart6.resize();
	maChart7.resize();
}

/***全屏按钮拖拽效果 - 开始***/
function fullScreenAllowDrop(ev){
	ev.preventDefault();
}

function fullScreenDrag(ev){
	ev.dataTransfer.setData("Text",ev.target.id);
}

function fullScreenDrop(ev,obj){
	var x = ev.clientX-obj.offsetLeft - 30;
    var y = ev.clientY-obj.offsetTop - 30;
    
    $(".fullScreenBut").css({"right": "auto","top": y+"px","left": x+"px"});
	ev.preventDefault();
}
/***全屏按钮拖拽效果 - 结束***/

//全屏按钮
function fullScreenClick(){
	var iframe = $(parent.document.body).find(".frameMain .con");
	var win_w = $(parent.document.body).width();
	var win_h = $(parent.document.body).find(".frameMenu").height();
	
	if(iframe.css("position") == "fixed"){
    	$(".fullScreenBut").css({"right": "10px","top": "60px","left": "auto"});
		$(".fullScreenBut").attr("class","iconfont icon-quanping fullScreenBut");
		iframe.css({
			"position":"static",
			"top":"0",
			"left":"0",
			"z-index":"1",
			"width":"100%",
			"height":(win_h - 92)+"px"
		});
	}else{
		$(".fullScreenBut").attr("class","iconfont icon-tuichuquanping fullScreenBut");
		iframe.css({
			"position":"fixed",
			"top":"0",
			"left":"0",
			"z-index":"1",
			"width":win_w+"px",
			"height":win_h+"px"
		});
	}
	//重新绘制报表
	fullScreenRefreshEcharts(totalAmountChart, weekActiveChart, payRatioChart, orderMapChart, merchantGraphChart, categorySingleChart, businessChart);
}

//千分位
function get_thousand_num(num) {
    return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
        return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
            return $1 + ",";
        });
    });
}

//初始化页面
function init(totalAmountData){
	totalAmount("totalAmount", totalAmountData);
}








//总金额
var totalAmountChart;
var COMPANY_VALUE = "";	//总金额 - 默认单位
var SPECIFICATION_TAG = "";//总金额 - 横坐标默认单位
function totalAmount(id,data){
    
    totalAmountChart = echarts.init(document.getElementById(id));

    option = {
    	    title: {
    	        text: '营业情况统计'
    	    },
    	    tooltip : {
    	        trigger: 'axis',
    	        axisPointer: {
    	            type: 'cross',
    	            label: {
    	                backgroundColor: '#6a7985'
    	            }
    	        }
    	    },
    	    legend: {
    	        data:['原价金额','折扣金额','实收金额'],
    	    	textStyle: {
    	    		color: '#FFF'
    	    	}
    	    },
    	    toolbox: {
    	        feature: {
    	            saveAsImage: {}
    	        }
    	    },
    	    grid: {
    	        left: '3%',
    	        right: '4%',
    	        bottom: '3%',
    	        containLabel: true
    	    },
    	    xAxis : [
    	        {
    	            type : 'category',
    	            boundaryGap : false,
    	            data : data.day
    	        }
    	    ],
    	    yAxis : [
    	        {
    	            type : 'value'
    	        }
    	    ],
    	    series : [
    	        {
    	            name:'折扣金额',
    	            type:'line',
    	            stack: '总量',
    	            areaStyle: {},
    	            data:data.discount
    	        },
    	        {
    	            name:'实收金额',
    	            type:'line',
    	            stack: '总量',
    	            areaStyle: {},
    	            data:data.official
    	        },
    	        {
    	            name:'原价金额',
    	            type:'line',
    	            stack: '总量',
    	            label: {
    	                normal: {
    	                    show: true,
    	                    position: 'top'
    	                }
    	            },
    	            areaStyle: {normal: {}},
    	            data:data.original
    	        }
    	    ]
    	};


    totalAmountChart.setOption(option);
}
